package com.clf.manager.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.clf.manager.entity.StudentCurrm;
import com.clf.manager.service.StudentCurrmService;
import com.clf.manager.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class StudentCurrmController {

    @Autowired
    StudentCurrmService studentCurrmService;

    @RequestMapping("/addCurrm")
    public Result add(
            @RequestParam("id") String id,
            @RequestParam("currmId") int currmid
    ){
        studentCurrmService.save(new StudentCurrm(id,currmid));
        return Result.fail();
    }

    @RequestMapping("/deleteCurrm")
    public Result delete(
            @RequestParam("id") String id,
            @RequestParam("currmId") int currmid
    ){
        QueryWrapper<StudentCurrm> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("student_id",id);
        queryWrapper.like("currm_id",currmid);
        studentCurrmService.remove(queryWrapper);
        return Result.fail();
    }
}
